'''
http 请求和响应
'''
from socket import *

sock = socket()
sock.bind(('0.0.0.0', 8888))
sock.listen(5)
# 等待浏览器连接
connfd, addr = sock.accept()
print('connect from', addr)
# 接受HTTP请求
request = connfd.recv(1024)
print(request.decode())
# 组织响应格式
response = '''HTTP/1.1 200 ok
Content -Type:text/html

Hello Word
'''
connfd.send(response.encode())

connfd.close()
sock.close()
